#ifndef DODO_DODO_USE_COUNT_H
#define DODO_DODO_USE_COUNT_H
/** example 
 * class Handle
 * {
 *     public:
 *         Handle() : p(new Point) { }
 *         Handle(const Point & p0) : p(new Point(p0)) { }
 *         Handle(const Handle & h) : u(h.u), p(h.p) { }
 *         ~Handle()
 *         {
 *             if ( u.only() )
 *                 delete p;
 *         }
 *
 *         Handle & operator= (const Handle& h)
 *         {
 *             if (u.reattach(h.u))
 *                 delete p;
 *             p = h.p;
 *             return *this;
 *         }
 *
 *         Handle & x(int x0)
 *         {
 *             if ( u.makeonly() )
 *                 p = new Point(*p);
 *             p->x(x0);
 *             return *this;
 *         }
 *
 *     private:
 *		   Point *p;
 *         UseCount u;
 * };
**/
namespace claydodo
{
	class UseCount
	{
	public:
		UseCount();
		UseCount(const UseCount &u);
	private:
		UseCount & operator= (const UseCount &);
	public:
		~UseCount();

		bool only(); //returns whether only one stuff points to it.
		bool reattach(const UseCount &); //re_attach one counter to another
		bool makeonly();
	private:
		int *p;
	};
}
	
#endif

